#include "help.h"

#define  STRINGHELP 4
std::string helpstring[STRINGHELP]=
{
	"",
	"This is a simple game",
	"it has  20 stages  in total. ",
	"Difficulty is divided into three."
};
helpLayer::helpLayer(void)
{
	initHelp();
}


helpLayer::~helpLayer(void)
{
}

void helpLayer::initHelp()
{
	CCSize size = CCDirector::sharedDirector()->getWinSize();
	CCSprite *helpSprite = CCSprite::spriteWithFile(BACKGROUND[9].c_str());
	helpSprite->setPosition(ccp(size.width/2,size.height/2));
	addChild(helpSprite);

	for (int i=0;i<STRINGHELP;++i)
	{
		CCLabelBMFont* pLabel1=CCLabelBMFont::labelWithString(helpstring[i].c_str(),FONT);
		pLabel1->setScale(0.5f);
		pLabel1->setColor(ccc3(0,250,250));
		pLabel1->setPosition(CCPointMake( pLabel1->getContentSize().width/4+10, (size.height-50*i)));
		addChild(pLabel1,i);
	}
	
	CCLabelBMFont* pLabel2=CCLabelBMFont::labelWithString("Back",FONT);
	pLabel2->setScale(0.7f);
	pLabel2->setColor(ccc3(140,250,0));
	CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(pLabel2, this, menu_selector(helpLayer::menuCallback));
	pMenuItem->setPosition(ccp( size.width/2, size.height/2-90));
	CCMenu *menu = CCMenu::menuWithItems(pMenuItem,NULL);
	menu->setPosition(CCPointZero);
	addChild(menu,10);
	
}

void helpLayer::menuCallback(CCObject* pSender)
{
	CCScene *pScene = HelloWorld::scene();
	CCScene *s=  CCTransitionFadeTR::transitionWithDuration(0.5, pScene); 
	CCDirector::sharedDirector()->replaceScene(s);
}